<?php

namespace app\index\model;

use think\Model;
use think\Db;
class Driver extends Model
{
    /**
     * 判断司机id是否重复
     * @param $DeriverId
     * @return int|string
     */
    public static function isRepeatDeriverId($DeriverId)
    {
        return Db::table('tb_driver')->where(['driver_id'=>$DeriverId])->count();
    }

    /**
     * 车辆是否被分配
     * @param $driver_id
     * @param $vehicle_id
     * @return int|string
     */
    public static function vehicleIsAssigned( $driver_id , $vehicle_id )
    {
        $count = Db::table('tb_driver')
            ->where(['vehicle_id'=>$vehicle_id])
            ->where('driver_id','<>',$driver_id)
            ->fetchSql(false)
            ->count();
        return $count;
    }

}
